package itheima.jdk8.stream;


import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class StreamTest12 {

    public static void main(String[] args) {
        List<String> list1 = Arrays.asList("2Hi", "1Hello", "3你好");
        List<String> list2 = Arrays.asList("zhangsan", "lisi", "wangwu", "zhaoliu");

        //二分归并查询？ 组合查询
        List<String> result = list1.stream().flatMap(item -> list2.stream().map(item2 -> item + " " + item2)).sorted(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return  o1.compareTo(o2);
            }
        }). collect(Collectors.toList());

        //报错：
        //System.out.println("合并list---》"+list1.addAll(list2));


        result.forEach(System.out::println);

    }

}
